﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using IndignadoFramework.PhoneApp.ServiceReferenceListarConvocatorias;
using IndignadoFramework.PhoneApp.Helper;

namespace IndignadoFramework.PhoneApp
{
    public partial class Page1 : PhoneApplicationPage
    {        

        public Page1()
        {
            InitializeComponent();
            var proxy = new PhoneServicesClient();
            proxy.ListarConvocatoriasCompleted += (s, ea) =>
            {
                if (!ea.Cancelled)
                {
                    listBox1.ItemsSource = ea.Result;
                }
                else
                {
                    listBox1.ItemsSource = new List<string>(){"Connection unavailable"};
                }
            };
            var file = SerializeHelper.LoadSetting("FacebookAccess");
                //new EventHandler<ListarConvocatoriasCompletedEventArgs>(proxy_ListarConvocatoriasCompleted);
            proxy.ListarConvocatoriasAsync(file.UserId);
        }

        void proxy_ListarConvocatoriasCompleted(object sender, ListarConvocatoriasCompletedEventArgs e)
        {
            listBox1.ItemsSource = e.Result;
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            var file = SerializeHelper.LoadSetting("FacebookAccess");

            var userId = this.NavigationContext.QueryString["id"].ToString();
            userId.Count();
        }
    }
}